var Data = function(slug, text)
{
    this.mSlug = slug;
    this.mText = text;
}
Data.prototype.write = function(par, key)
{
    var el = document.createElement("div")
    el.innerHTML = "<i>" + key + "</i> <b>" + this.mSlug + ":</b> " + this.mText;
    par.appendChild(el);
}

var input = [];
input.push(new Data("foo", "This is foo"));
input.push(new Data("bar", "This is bar"));
input.push(new Data("baz", "This is baz"));

function writeArray(id, array)
{
    var el = document.getElementById(id);
    for (var d in array) {
	array[d].write(el, d);
    }
}
writeArray("before", input);

input.sort(function(a,b) { a.mSlug.localeCompare(b.mSlug); });

writeArray("after", input);


	
	
